{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Python \t\t3.6\n",
      "Tensorflow \t1.0.0\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Using TensorFlow backend.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Keras \t\t2.0.3\n"
     ]
    }
   ],
   "source": [
    "import sys; print('Python \\t\\t{0[0]}.{0[1]}'.format(sys.version_info))\n",
    "import tensorflow as tf; print('Tensorflow \\t{}'.format(tf.__version__))\n",
    "import keras; print('Keras \\t\\t{}'.format(keras.__version__))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true,
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "%matplotlib inline \n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "plt.style.use('ggplot')\n",
    "\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#linear regression, with additive noise\n",
    "f = lambda x, e: 2*x + 3 + e\n",
    "f_vec =  np.vectorize(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "samples = 1000\n",
    "e = np.random.normal(0.0, 0.2, samples)\n",
    "x = np.random.rand(samples)\n",
    "y = f_vec(x,e)\n",
    "\n",
    "# transform into columns\n",
    "x = x.reshape(-1,1)\n",
    "y = y.reshape(-1,1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAT8AAAEyCAYAAACMONd1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/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iMYyMjMDn85naTi209AUAenp68Je//AVbtmyRtlxU68vNmzdx5coVPPfcc3jy\nySfx4YcfYvv27fjoo4+saG5GWr/HgsEgCgoKMGvWLMyZMwdXr141u6mqtPTl6NGjqKmpAQAsWrQI\n0WhUykpJC7/fj76+vsnX6X6mtJIq/KqqqnD16lX897//xdjYGE6cOIHglOfvLl26FMeOHQMwvrJY\nXV0NRVEsaG1mWvry8ccf449//CO2bNki7bwSoN6XkpISvPzyy9i7dy/27t2LhQsXYsuWLVKu9mr5\nd/n617+O8+fPAwBu3LiBq1evYvbs2VY0NyMtfQkEAjh37hwA4NNPP0U0GsXMmTOtaG7egsEgOjs7\nIYTAxYsXUVJSktccpnR3eJw5cwavvvoq4vE4vvWtb+Hhhx9Ge3s7qqqqEAwGEYlEsGfPHnz88cco\nLS3Fxo0bpfzGBNT78vzzz+OTTz7BXXfdBWD8G3Xr1q0Wtzo1tb4kevbZZ/GDH/xAyvAD1PsihMBr\nr72Gs2fPYtq0aXj44YfxjW98w+pmp6TWl08//RT79u3DzZs3AQCNjY348pe/bHGrU/vd736Hf//7\n3xgaGkJZWRnWrl2LsbExAMDKlSshhMDLL7+Mf/7znygsLERTU1Ne32PShR8RkRmkKnuJiMzC8CMi\nV2L4EZErMfyIyJUYfkTkSgw/InIlhh8RudL/A4Sn+Xg2XnssAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1198a7710>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(5,5))\n",
    "plt.plot(x[:100], y[:100], 'r.')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.01, random_state=42)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from keras.models import Sequential\n",
    "from keras.layers.core import Dense"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "model = Sequential()\n",
    "model.add(Dense(1, input_dim=1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "model.compile(optimizer='sgd', loss='mean_squared_error', metrics=[\"accuracy\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train on 990 samples, validate on 10 samples\n",
      "Epoch 1/10\n",
      "990/990 [==============================] - 0s - loss: 2.0997 - acc: 0.0000e+00 - val_loss: 0.0654 - val_acc: 0.0000e+00\n",
      "Epoch 2/10\n",
      "990/990 [==============================] - 0s - loss: 0.0703 - acc: 0.0000e+00 - val_loss: 0.0497 - val_acc: 0.0000e+00\n",
      "Epoch 3/10\n",
      "990/990 [==============================] - 0s - loss: 0.0575 - acc: 0.0000e+00 - val_loss: 0.0514 - val_acc: 0.0000e+00\n",
      "Epoch 4/10\n",
      "990/990 [==============================] - 0s - loss: 0.0501 - acc: 0.0000e+00 - val_loss: 0.0484 - val_acc: 0.0000e+00\n",
      "Epoch 5/10\n",
      "990/990 [==============================] - 0s - loss: 0.0457 - acc: 0.0000e+00 - val_loss: 0.0479 - val_acc: 0.0000e+00\n",
      "Epoch 6/10\n",
      "990/990 [==============================] - 0s - loss: 0.0430 - acc: 0.0000e+00 - val_loss: 0.0428 - val_acc: 0.0000e+00\n",
      "Epoch 7/10\n",
      "990/990 [==============================] - 0s - loss: 0.0414 - acc: 0.0000e+00 - val_loss: 0.0445 - val_acc: 0.0000e+00\n",
      "Epoch 8/10\n",
      "990/990 [==============================] - 0s - loss: 0.0405 - acc: 0.0000e+00 - val_loss: 0.0475 - val_acc: 0.0000e+00\n",
      "Epoch 9/10\n",
      "990/990 [==============================] - 0s - loss: 0.0400 - acc: 0.0000e+00 - val_loss: 0.0469 - val_acc: 0.0000e+00\n",
      "Epoch 10/10\n",
      "990/990 [==============================] - 0s - loss: 0.0396 - acc: 0.0000e+00 - val_loss: 0.0473 - val_acc: 0.0000e+00\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<keras.callbacks.History at 0x11cab6f28>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.fit(x_train, y_train,\n",
    "          batch_size=5, epochs=10, verbose=1,\n",
    "          validation_data=(x_test, y_test))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Test accuracy (MSE): 0.0472749248147\n"
     ]
    }
   ],
   "source": [
    "score = model.evaluate(x_test, y_test, verbose=0)\n",
    "print('Test accuracy (MSE):', score[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0.41693318,  3.83040857],\n",
       "       [ 0.75587638,  4.48687649],\n",
       "       [ 0.46316869,  3.91995764],\n",
       "       [ 0.65306373,  4.28774786],\n",
       "       [ 0.60201791,  4.18888187],\n",
       "       [ 0.71632451,  4.41027164],\n",
       "       [ 0.54853563,  4.08529711],\n",
       "       [ 0.84786116,  4.66503334],\n",
       "       [ 0.17868096,  3.3689599 ],\n",
       "       [ 0.63185176,  4.24666452]])"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_test_predict = model.predict(x_test)\n",
    "np.hstack([x_test[:10],y_test_predict[:10]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Regression a = 1.9, b = 3.0\n"
     ]
    }
   ],
   "source": [
    "w, b = model.layers[0].get_weights()\n",
    "w_ = w[0][0]\n",
    "b_ = b[0]\n",
    "print(\"Regression a = {:.2}, b = {:.2}\".format(w_, b_))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAT8AAAEyCAYAAACMONd1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl01GWe7/H3r5bslaVSgiYO3galveKg05ReYo/gNFEB\nu0G4aBSRCIooCiKtBOVIxGUSEWllycAoggojEYdWSYNLGhloJGoEmwZtacSV5UpSIXtSlfr97h8h\nsRKSVFVSe31f5/Q5JvWr5HlC8ulnfxRN0zSEECLK6IJdACGECAYJPyFEVJLwE0JEJQk/IURUkvAT\nQkQlCT8hRFSS8BNCRCUJPyFEVJLwE0JEJQk/IURUMgTzmx8/ftyr5y0WCxUVFX4qTeBESj1A6hKq\nIqUuvalHRkaGR89Jy08IEZUk/IQQUUnCTwgRlST8hBBRScJPCBGVJPyEEFFJwk8IEZUk/IQQUSmo\ni5yFEKIrxvJyYvfuRRkzBi680C/fQ1p+QoiQYiwvJz0nB9Ozz2IYPRpjeblfvo+EnxAipMTu3Yvi\ncKA4nWC3E7t3r1++j4SfECKkNGdloRmNaHo9xMTQnJXll+8jY35CiJDisFqpLC4mdu9e4seMweGn\nMT8JPyFEyHFYrTisVuIsFvDT6TTS7RVCRCUJPyFEVJLwE0JEJQk/IURUkvATQkQlCT8hRFSS8BNC\nRCUJPyFEVJLwE0JEJQk/IURUkvATQkQlCT8hRFSS8BNCRCWPTnW57777iIuLQ6fTodfrKSws7PC6\npmmsW7eO/fv3Exsby6xZsxg4cKBfCiyEEL7g8ZFW+fn5JCcnd/na/v37OXnyJMuXL+cf//gHL730\nEv/+7//us0IKIYSv+aTbW15ezogRI1AUhcGDB1NfX09VVZUvvrQQQviFxy2/p59+GoBrr72W7Ozs\nDq/ZbDYsFk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OfPP/+cdevWoaoqo0aN4sYbb+zwusPhYOXKlRw9ehSTycTc\nuXPp169fkErbPXf1KCkp4c9//jN6vZ7k5GTuvfdezjnnnCCVtmfu6tKmrKyMZcuWUVBQwKBBgwJc\nSs94UpePPvqIzZs3oygKF1xwAQ888EAQStozd/WoqKhg1apV1NfXo6oqkydP5le/+lWQStuzoqIi\n9u3bR0pKCs8999xZr2uaxrp169i/fz+xsbHMmjWr72OBWohxOp3a/fffr508eVJzOBzaQw89pP3w\nww8dnnn33Xe1NWvWaJqmaX/5y1+0ZcuWBaOoPfKkHn/729+0pqYmTdM07b333gvJemiaZ3XRNE1r\naGjQFi1apD366KPakSNHglBS9zypy/Hjx7WHH35Yq62t1TRN006fPh2MovbIk3qsXr1ae++99zRN\n07QffvhBmzVrVjCK6pFDhw5pX3/9tTZv3rwuX//ss8+0p59+WlNVVfvqq6+0Rx55pM/fM+S6vUeO\nHOHcc8+lf//+GAwGrrrqKj799NMOz5SXl3PNNdcAMHz4cA4ePIgWYvM2ntTj0ksvJTY2FoCLLroI\nm80WjKK65UldAIqLixk/fjxGozEIpfSMJ3X585//zPXXX09SUhIAKSkpwShqjzyph6IoNDQ0ANDQ\n0EBaWlowiuqRSy65pP3n3ZXy8nJGjBiBoigMHjyY+vp6qqqq+vQ9Qy78bDYb6enp7R+np6efFQqu\nz+j1ehISEqitrQ1oOd3xpB6uduzYweWXXx6IonnNk7ocPXqUioqKkO1WtfGkLsePH+fEiRM89thj\nLFy4kM8//zzQxXTLk3rcdNNN7N69m3vuuYeCggKmT58e6GL6jM1mw2KxtH/s7u/JEyEXftFo165d\nHD16lHHjxgW7KL2iqiqvvvoqU6dODXZRfEJVVU6cOEF+fj4PPPAAa9asob6+PtjF8tqePXu45ppr\nWL16NY888ggrVqxAVdVgFytkhFz4mc1mKisr2z+urKzEbDZ3+4zT6aShoQGTyRTQcrrjST0ADhw4\nwB//+Efmz58fst1Fd3Vpamrihx9+YPHixdx333384x//YMmSJXz99dfBKG6PPP39slqtGAwG+vXr\nx3nnnceJEycCXdQeeVKPHTt2kJWVBcDgwYNxOBwh10PylNlspqKiov3j7v6evBFy4Tdo0CBOnDjB\nTz/9REtLCx999BHWTvfvDhs2jJ07dwKts4tDhgxBUZQglLZ7ntTjm2++4cUXX2T+/PkhOa7Uxl1d\nEhISWLt2LatWrWLVqlVcdNFFzJ8/PyRnez35d7nyyis5dOgQADU1NZw4cYL+/fsHo7jd8qQeFouF\ngwcPAvDjjz/icDhITk4ORnH7zGq1smvXLjRN4/DhwyQkJPR5DDMkd3js27ePV155BVVV+bd/+zcm\nTpxIcXExgwYNwmq1YrfbWblyJd988w1JSUnMnTs35H45wX09nnzySb7//ntSU1OB1l/WvLy8IJe6\na+7q4urxxx/n9ttvD8nwA/d10TSNV199lc8//xydTsfEiRP59a9/Hexin8VdPX788UfWrFlDU1MT\nAFOmTOGyyy4Lcqm79vzzz/PFF19QW1tLSkoKN998My0tLQBcd911aJrG2rVr+etf/0pMTAyzZs3q\n8+9XSIafEEL4W8h1e4UQIhAk/IQQUUnCTwgRlST8hBBRScJPCBGVJPyEEFFJwk8IEZX+P1M0gc7p\nEvCiAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x11cadccf8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(5,5))\n",
    "plt.plot(x[:100], y[:100], 'r.')\n",
    "plt.plot(x_test, y_test_predict, 'bo')\n",
    "plt.plot([b_,w_*1+b_], 'b-')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
